<?php
	include_once "xAP-functions/webincludes.php";

$results=dbquery("SELECT SourceID,Location,Alias,SourceType FROM xap_pictures_source order by SourceType,Alias");

foreach($results as $r){
	if ($r["SourceType"]==0){
		$src[$r["SourceID"]]["lcn"]=$r["Location"];
		$src[$r["SourceID"]]["name"]=$r["Alias"];
		$src[$r["SourceID"]]["type"]=$r["SourceType"];
	}
	if ($r["SourceType"]==1){
		$cctv[$r["SourceID"]]["lcn"]=$r["Location"];
		$cctv[$r["SourceID"]]["name"]=$r["Alias"];
		$cctv[$r["SourceID"]]["type"]=$r["SourceType"];
	}
}

$q="?";
header("Content-type: text/xml");
?>
<<?=$q?>xml version="1.0" encoding="UTF-8"?>
<root>
<title set="waPicturesSources">Picture Sources</title>
<part>
<destination mode="replace" zone="waPicturesSources"  create="true"/>
<data><![CDATA[
<div class="iMenu">
<?if(isset($cctv)):?>
<h3>CCTV</h3>
<UL class='iArrow'>
<? foreach($cctv as $k=>$v):?>
<LI class='iArrow'><a href='/Pictures/iphone_cctv.php?type=0&id=<?=$k?>#_PicturesList0' rev="async"><?=$v["name"];?></a></LI>
<? endforeach; ?>
</UL>
<?endif;?>

<?if(isset($src)):?>
<h3>Pictues</h3>
<UL class='iArrow'>
<? foreach($src as $k=>$v):?>
<LI class='iArrow'><a href='/Pictures/iphone_pics.php?root=source&id=<?=$k?>#_PicturesList0' rev="async"><?=$v["name"];?></a></LI>
<? endforeach; ?>
</UL>
<?endif;?>
</div>
]]></data>
</part>
</root>